<?php
/**
 * 友の会用フォーム・モデルクラス<br />
 *
 * @package apamanshop
 * @author H.Imamura
 * @copyright (c) 2013 SystemSoft Corp. All rights reserved
 */
class Inquiry_Model_Tomonokai extends Inquiry_Model_Apibase
{
	/**
	 * 応募ログ登録
	 *
	 * @return 
	 */
	public function insertEntryLog($params, $db)
	{
		$db_params = array();
		
		$sql  = "INSERT INTO ASTOMO.TMO_APPLY_CAMPAIGNS (";
		$sql .= "  CAMPAIGN_CD";
		$sql .= " ,MEMBER_ID";
		$sql .= " ,EMAIL";
		$sql .= " ,APPLY_DATE";
		$sql .= " ,OPERATOR_ID";
		$sql .= " ,CREATED";
		$sql .= " ,MODIFIED";
		$sql .= ") VALUES (";
		$sql .= "  :campaign_cd";
		$sql .= " ,:member_id";
		$sql .= " ,:email";
		$sql .= " ,to_date(:apply_date, 'yyyyMMddhh24miss')";
		$sql .= " ,:operator_id";
		$sql .= " ,sysdate";
		$sql .= " ,sysdate";
		$sql .= ")";
		
		$db_params['campaign_cd'] = $params['CampaignCd'];
		$db_params['member_id']   = $params['MemberId'];
		$db_params['email']       = $params['Email'];
		$db_params['apply_date']  = $params['ApplyDate'];
		$db_params['operator_id'] = $params['MemberId'];
		
		return $this->dbExecQuery($sql, $db_params, $db);
	}

	/**
	 * メンバーID検索
	 *
	 * @return 
	 */
	public function selectMemberIdForLoginId($params, $db)
	{
		$member_id = '';
		$db_params = array();
		
		$sql  = "SELECT";
		$sql .= "     tme.MEMBER_ID";
		$sql .= "    ,tme.MEMBER_NAME";
		$sql .= "    ,tlo.PASSWORD";
		$sql .= "    ,tlo.STATUS";
		$sql .= "  FROM";
		$sql .= "     ASTOMO.TMO_LOGINS tlo";
		$sql .= "    ,ASTOMO.TMO_MEMBERS tme";
		$sql .= " WHERE";
		$sql .= "     (tlo.STATUS = '0' or tlo.STATUS = '2')";
		$sql .= " AND tlo.LOGIN_ID = :login_id";
		$sql .= " AND tlo.MEMBER_ID = tme.MEMBER_ID";
		
		$db_params['login_id'] = $params['LoginId'];
		
		return $this->dbGetData($sql, $db_params, $db);
	}

}
?>
